/*
 *  Resource.cpp
 *  SypXIPhone
 *
 *  Created by Luv Khemani on 5/14/10.
 *  Copyright 2010 Luv Khemani. All rights reserved.
 *
 */
#ifdef SYPX_MEMCHECK
#include "mmgr.h"
#endif

#include "Resource.h"
#include "ResourceManager.h"


namespace SypX
{
	UInt Resource::uniqueID = 0;

	UInt Resource::getUniqueID()
	{
		return uniqueID++;
	}
	Resource::Resource()
	{		
		count = 0;
	}
	
	void Resource::setFileName(const String& file)
	{
		if(filename=="")
		{//only set filename if we don't have one set
			filename = file;
			ResourceManager::getSingleton()->registerResource(this);
		}
	}

	UInt Resource::getNumRef()
	{
		return count;
	}

	Resource::~Resource()
	{		
		assert(count == 0 && "Resource was deleted while still being referenced!");

	}
	
	void Resource::addRef()
	{
		++count;
	}
	
	void Resource::removeRef()
	{
		--count;
	}

	const String& Resource::getFileName()
	{
		return filename;
	}
	
	
	
	
}